

#ifndef _INETADDRESS_H_
#define _INETADDRESS_H_

#include "noncopyable.hpp"
#include <netinet/in.h>
#include <string>


namespace zephyr {

class InetAddress {
  public:
    explicit InetAddress(uint16_t port = 0, std::string = "127.0.0.1");
    explicit InetAddress(const struct sockaddr_in &addr) : m_addr(addr) {}

    std::string toIp() const;
    std::string toIpPort() const;
    uint16_t toPort() const;

    const struct sockaddr_in *getSockaddr() const { return &m_addr; }
    void setSockaddr(const struct sockaddr_in &addr) { m_addr = addr; }


  private:
    struct sockaddr_in m_addr;
};

}

#endif // _INETADDRESS_H_